import request from "@/utils/request";
import {Bookmark} from "@/api/sys/my/bookmark/types";
import { PATH_SYS_MY} from "@/utils/constant";

const baseUrl = PATH_SYS_MY + '/bookmark/'

/**
 * 查询书签列表 - 带分页
 * @param data
 */
export function getBookmarkListApi(data: PageQuery<Bookmark>): PromisePageListType<Bookmark> {
    return request.post(baseUrl + 'list', data)
}

/**
 * 通过书签id获取书签信息
 * @param id
 */
export function getBookmarkByIdApi(id: number): Promise<Bookmark> {
    return request.get(baseUrl + id)
}

/**
 * 修改书签
 * @param id
 * @param data
 */
export function editBookmarkApi(id:number,data: Bookmark): Promise<any> {
    return request.patch(baseUrl+id, data)

}

/**
 * 添加书签
 * @param data
 */
export function addBookmarkApi(data: Bookmark): Promise<any> {
    return request.post(baseUrl, data)
}

/**
 * 删除书签
 * @param id
 */
export function deleteBookmarkApi(id: number): Promise<any> {
    return request.delete(baseUrl + id)
}

// 点击的时候次数加1
export function addBookmarkCount(id: number): Promise<any> {
    return request.patch(baseUrl + `count/${id}`)
}
